<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            X-admin v1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form action="" method="post" class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>ID
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="id" autocomplete="off" class="layui-input" value="{$set_info.id}" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>奖品名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="lw_name" required="" lay-verify="required" autocomplete="off" class="layui-input" value="{$set_info.lw_name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>抽中机率
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="v" required="" lay-verify="required" autocomplete="off" class="layui-input" value="{$set_info.v}">
                    </div>
                    <span style="color: red;font-size: 8px;position: absolute;top: 135px;">注意：所有奖项几率总和为100，如果值为1，则代表中奖几率为1%;</span>
                </div>

                <div class="layui-form-item">
                    <button class="layui-btn" lay-submit="" lay-filter="add">修改</button>
              </div>
            </form>
            <!-- 中奖信息 -->
           <table class="layui-table">此奖品抽奖列表
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>
                        <th>
                            抽奖手机
                        </th>
                        <th>
                            抽奖时间
                        </th>
                    </tr>
                </thead>
                <tbody id="x-link">
                <?php foreach ($cj_info as $v) { ?>
                    <tr>
                        <td>
                            {$v.id}
                        </td>
                        <td>
                            <?php echo re_phone($v['phone_id']) ?>
                        </td>
                        <td>
                            <?php echo date('Y-m-d H:i:s',$v['cj_time']) ?>
                        </td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
        </div>
        <script src="__PUBLIC__/admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="__PUBLIC__/admin/js/x-layui.js" charset="utf-8">
        </script>
        <script>
            layui.use(['form','layer','layedit' ,'laypage', 'element','upload'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,laypage = layui.laypage
              ,layedit = layui.layedit
              ,element = layui.element()
              ,upload = layui.upload
              ,layer = layui.layer;

              //监听提交
              form.on('submit(add)', function(data){
                //发异步，把数据提交给php
                $.ajax({
                    url: "{:U('admin/cj/set_edit_add')}",//请求地址
                    type: "post",//请求方式
                    dataType: "json",//返回数据类型
                    data: data.field,//发送的参数
                    })
                    .done(function(response) {
                          if(response.error==0){
                             layer.msg(response.info ,{icon:5});
                          }else{
                            layer.alert(response.info, {icon: 6},function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                parent.location.reload();

                            });
                          }
                      })
                    .fail(function() {
                        alert("ajxs交互失败");
                    })  
                return false;
              });
              
              
            });
        </script>
    </body>

</html>